$(function(){
mainBannerGo()
	new_share()
	setTimeout(waterFallPos,300);
	setTimeout(waterFallPos,1000);
	$(window).resize(function(){setTimeout(waterFallPos,13);});
	
	imgRemove()
	headOn()
	caseNavHover();
	bodySmallWidth();
	$(window).resize(bodySmallWidth);
	$(".share_box_inner li").eq($(".share_box_inner li").length-1).find(".share_fg").remove();
	
})
/*1000宽度*/
function bodySmallWidth(){
	var windowWidth=$(window).width();
	if(windowWidth>1280){
		$("body").removeClass("body_small_width");
	}else if(windowWidth<1280){
		$("body").addClass("body_small_width");
	}
}
/*头部判断*/
function headOn(){
	/*头部判断*/
	var objUrl=window.location.href;
	var om=objUrl.split("&");
	var aboutus=objUrl.split("/");
	var catid;
	for(i=0;i<om.length;i++){
		var b=om[i].indexOf("catid")
		if(om[i].indexOf("catid")>-1){
			catid=om[i].split('=')[1];		
	}}
	if(aboutus[aboutus.length-2]=="aboutus"){$(".header .navbox li").eq(1).addClass("on");}
	else if(aboutus[aboutus.length-2]=="news"){$(".header .navbox li").eq(2).addClass("on");}
	switch(catid){
	case "11":
		
		$(".header .navbox li").eq(0).addClass("on");
		break;
	case "16":
		$(".header .navbox li").eq(0).addClass("on");
		$(".case .case_select li").eq(1).addClass("navhover");
		break;
	case "17":
		$(".header .navbox li").eq(0).addClass("on");
		$(".case .case_select li").eq(2).addClass("navhover");
		break;	
	case "18":
		$(".header .navbox li").eq(0).addClass("on");
		$(".case .case_select li").eq(3).addClass("navhover");
		break;		
		}
}
function caseNavHover(){
	var hoverOn=$(".case .case_select .navhover");
	$(".case .case_select li").hover(
	function(){$(this).addClass("navhover");},
	function(){
		$(this).removeClass("navhover"),
		hoverOn.addClass("navhover")
	}
	)
}
function imgRemove(){
	$(".sub_title_lbox img").remove();
}
/*waterFall*/
function waterFallPos(){
	var fallHeight=[0,0,0,0];
	var waterfall=$(".new_share_box_inner");
	var smallHeight=0;
	var wWidth=$(window).width();
	var waterfallbox_width;
	if(wWidth<1280){waterfallbox_width=1000/4;}else{waterfallbox_width=$(".new_share_box_inner").width()/4;}
	var objLi;
	var fallObj=$(".new_share_box_inner .new_share_boxs");
	for(i=0;i<fallObj.length;i++){
		objLi=fallObj.eq(i);
		if((i+1)%4==1){	/*第一纵*/		
			fallHeight[0]+=(objLi.height()+50);
			objLi.attr({"style":"left:0px;top:"+(fallHeight[0]-objLi.height())+"px"});
		}
		if((i+1)%4==2){	/*第二纵*/		
			fallHeight[1]+=(objLi.height()+50);
			objLi.attr({"style":"left:"+(waterfallbox_width+7)+"px;top:"+(fallHeight[1]-objLi.height())+"px"});
		}
		if((i+1)%4==3){	/*第三纵*/		
			fallHeight[2]+=(objLi.height()+50);
			objLi.attr({"style":"left:"+(waterfallbox_width*2+11)+"px;top:"+(fallHeight[2]-objLi.height())+"px"});
		}
		if((i+1)%4==0){	/*第三纵*/		
			fallHeight[3]+=(objLi.height()+50);
			objLi.attr({"style":"left:"+(waterfallbox_width*3+15)+"px;top:"+(fallHeight[3]-objLi.height())+"px"});
		}
	}
	for(i=0;i<fallHeight.length;i++){		
		if(smallHeight<fallHeight[i]){smallHeight=fallHeight[i];}
	}
	waterfall.attr({"style":"height:"+(smallHeight+50)+"px"})	
}
function new_share(){
	$(".new_share_nav_box a").click(function(){$(this).parents(".new_share_nav_box").find(".on").removeClass("on"),$(this).addClass("on")});
	$(".new_share_boxs a").click(
	function(){
		$(".new_share_poup").removeClass("none")
		$(".new_share_poup .bg").animate({"opacity":"0.6"},600);
	}
	
	);
	$(".new_share_poup_area .close").click(function(){$(".new_share_poup").addClass("none");$(".new_share_poup .bg").attr({"style":"opacity:1"})});
}

function mainBannerGo(){
	$(".new_share_js_inner ul").stop();
	var sWidth = $(".new_share_js_inner").width(); //获取焦点图的宽度（显示面积）*/
	var sHeight=$(".new_share_js_inner ul").height();
	var len = $(".new_share_js_inner li").length; //获取焦点图个数
	var index = 0;
	var picTimer;
	
	$(".main_banner_js a").remove();
	for(i=0;i<len;i++){$(".main_banner_js").append('<a href="javascript:;"></a>');}
	//为小按钮添加鼠标滑入事件，以显示相应的内容
	$(".new_share_js .pre").click(function() {
		if(index>0){index -=1}else if(index==0){index=len-1}
		clearInterval(picTimer);
		showPics(index);
	});
	$(".new_share_js .next").click(function() {
		if(index<len-1){index +=1}else if(index==len-1){index=0}
		clearInterval(picTimer);
		showPics(index);
	});
picTimer = setInterval(function() {
			showPics(index);
			index++;
			if(index == len) {index = 0;}
		},4000); //此4000代表自动播放的间隔，单位：毫秒

	//本例为左右滚动，即所有li元素都是在同一排向左浮动，所以这里需要计算出外围ul元素的宽度
	$(".new_share_js_inner ul").css("width",sWidth * (len));
	
	//鼠标滑上焦点图时停止自动播放，滑出时开始自动播放
	$(".new_share_js_inner,.new_share_js .pre,.new_share_js .next").hover(function() {
		clearInterval(picTimer);
	},function() {
		picTimer = setInterval(function() {
			showPics(index);
			index++;
			if(index == len) {index = 0;}
		},4000); //此4000代表自动播放的间隔，单位：毫秒
	});
	//显示图片函数，根据接收的index值显示相应的内容
	function showPics(index) { //普通切换
		var nowLeft = -index*sWidth; //根据index值计算ul元素的left值
		$(".new_share_js_inner ul").stop().animate({"left":nowLeft},700); //通过animate()调整ul元素滚动到计算出的position	
	}
}



